package com.shuangti.storage.controller;


import com.shuangti.storage.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class StorageRestController {
    @Autowired
    StorageService storageService;

    @GetMapping("/deduct")
    public String deduct(@RequestParam("product_id") Long product_id,
                         @RequestParam("stock") Integer stock){
        storageService.deduct(product_id,stock);

        return "库存扣减成功！";
    }


    @GetMapping("/getPrice")
    public BigDecimal getPrice(@RequestParam("product_id") Long product_id){
        return storageService.getPrice(product_id);
    }
}
